package com.dhcc.consumer.listener.annoatationListener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class MessageAnnoatationListener01 {
	
	@RabbitListener(bindings = @QueueBinding(
			value = @Queue(value = "queue-01",durable = "true"),
			exchange = @Exchange(value = "direct-rabbit-exchange",type = ExchangeTypes.DIRECT),
			key = {"info"}
	))
	public void listenerSimple(Message message) {
		// message分装了消息
		byte[] body = message.getBody();
		String content = new String(body);
		System.out.println("MessageListener01...msg01 ----->" + content);
	}
}
